function applyBeInsManager() {
	$.ajax({
		type : "post",
		url : Server + "/userCenter/boolRoot",
		async:false,
		data : {
			uId : $("#useridoflogin").val()
		},
		success : function(res) {
			var html =
//		'<div class="right">'+
		' <div class="title"><span id="span1">申请仪器管理人</span></div>'
		+'<div class="tab_header" id="topThings">'
		+'</div>'  
		+'<div class="infoList">'
		+'<ul id="orderList">'
		+' <!--info-person-->'
		
		+'<style>.tab_header{display:none}'
		+' .mainList .content .right .infoList li {'
		+' height: 100%; '
		+' margin-bottom: 0px; '
		+' border: 0px solid #e6e6e6; '
		+'}			</style>'
		
		+' <div class="info-person">'
		+' 	<ul>'
		+' 		<li class="xixihahawowo">'
		+' 			<label class="wahaha">用户名&nbsp;</label>'
		+' 			<input id="userName" class="xixixdsfsafasfafasd" type="text" name=""  value="" />'
		+' 	    </li>'
		+'		<li class=\"item4\">	'
		+'			<label>所属机构<span>*</span></label>	'	
		+'			<select id="na">	'
		+'			</select>	'
		+'   	</li>'
		+' 		<li class="xixihahawowo">'
		+' 			<label class="wahaha">真实姓名</label>'
		+' 			<input id="realName" class="xixixdsfsafasfafasd" type="text" name=""  value="" />'
		+' 		</li>'
		+' 	<li class="xixihahawowo">'
		+' 		<label class="wahaha">职位</label>'
		+' 		<input id="post" class="xixixdsfsafasfafasd" type="text" name=""  value="" />'
		+' 	</li>'
		+' 	<li class="xixihahawowo">'
		+' 			<label class="wahaha">联系电话</label>'
		+' 		<input id="mobile" class="xixixdsfsafasfafasd" type="text" name=""  value="" />'
		+' 	</li>'
		+' 	<li class="xixihahawowo">'
		+' 		<label class="wahaha">电子邮箱</label>'
		+' 		<input id="emaile" class="xixixdsfsafasfafasd" type="text" name=""  value="" />'
		+' 	</li>'
		+' 	<li class="xixihahawowo">'
		+' 			<label class="wahaha">身份证件</label>'
		+' 			<input id="idCard" class="xixixdsfsafasfafasd" type="text" name=""  value="" />'
		+' 	</li>'
		+' </ul>'
		+' </div>'
		+' <!--btn-->'
		+'			<div class="btn-info-person"> '	
		+'			<a  id="btn-sub" class="btn-one">申请仪器管理人员</a>'
		+'		</div>'
		+' </div>'
//		+' </div>'
		+'<link rel="stylesheet" href="new_css/user3.css">'
		+'</div>'
		+'</ul>'
			$("#right333").html(html);
			console.log(res)
			/*
			 * if(res>0){ $("#btn-sub").css("background","rgb(220, 218,
			 * 215)") }else{ $("#btn-sub").click(function(){ submit() }) }
			 */
			if (res.checkResult == 1) {// 有审核记录 审核记录为待审核
				// 显示记录，但不可以操作
				$.ajax({
					type : "get",
					async : false,
					url : Server + "/userCenter/getNames",
					// url :"http://localhost/userCenter/getNames",
					success : function(res) {

						// alert("success");

						$("#na").append('<option value=" "> </option>')
						for (var i = 0; i < res.length; i++) {
							$("#na").append('<option value=\"' + res[i].id + '\">' + res[i].unitName
									+ '</option>')
						}
					}
				})
				$("#userName").val(res.username)
				$("#na").val(res.ouId)
				$("#realName").val(res.realname)
				$("#post").val(res.post)
				$("#mobile").val(res.phone)
				$("#emaile").val(res.email)
				$("idCard").val(res.idCard)
				$("#btn-sub").html("正在审核")
				$("#btn-sub").css("background", "rgb(220, 218, 215)")
			} else if (res.checkResult == 2) {// 有审核记录，但是审核记录 为 审核失败
												// 显示内容
				// 但是可以重新提交
				$.ajax({
					type : "get",
					async : false,
					url : Server + "/userCenter/getNames",
					// url :"http://localhost/userCenter/getNames",
					success : function(res) {

						// alert("success");

						$("#na").append('<option value=" "> </option>')
						for (var i = 0; i < res.length; i++) {
							$("#na").append('<option value=\"' + res[i].id + '\">' + res[i].unitName
									+ '</option>')
						}
					}
				})
				alert("审核失败，请重新输入信息提交至审核")
				$("#userName").val(res.username)
				$("#na").val(res.ouId)
				$("#realName").val(res.realname)
				$("#post").val(res.post)
				$("#mobile").val(res.phone)
				$("#emaile").val(res.email)
				$("idCard").val(res.idCard)
				$("#btn-sub").html("重新提交")
				$("#btn-sub").click(function() {
					update()
				})
			}else if(res.checkResult==null || res==""){ // 无审核记录 需要新增
				$.ajax({
					type : "get",
					async : false,
					url : Server + "/userCenter/getNames",
					// url :"http://localhost/userCenter/getNames",
					success : function(res) {
						console.log(res)
	
						// alert("success");
	
						$("#na").append('<option value=" "> </option>')
						for (var i = 0; i < res.length; i++) {
							$("#na").append('<option value=\"' + res[i].id + '\">' + res[i].unitName
									+ '</option>')
						}
					}
				}),
				$("#btn-sub").click(function() {
					insert()
				})
			}
			
		},
		error : function(){
			alert("error")
		}
	}),
	$.ajax({
		type : "post",
		// url:Server+"/userCenter/selectInfo",
		url : Server + "/userCenter/selectInfo",
		data : {
			uId : $("#useridoflogin").val()
		},
		success : function(res) {
			console.log(res)
			$("#userName").val(res.userName)
			/*
			 * $("#unitName").val(res.unitName)
			 * $("#unitAddress").val(res.unitAddress)
			 */
			$("#realName").val(res.realName)
			$("#mobile").val(res.mobile)
			$("#emaile").val(res.emaile)
			$("#idCard").val(res.idCard)
		}
	})
}
function submit() {
	if ($("#na").val() == " ") {
		alert("你未选择所属机构！")
	} else {
		$.ajax({
			type : "post",
			url : Server + "/userCenter/insertInfo",
			data : {
				uId : $("#useridoflogin").val(),
				unitName : $("#na").find("option:selected").text(),
				ouId : $("#na").val(),
				username : $("#userName").val(),
				realname : $("#realName").val(),
				post : $("#post").val(),
				phone : $("#mobile").val(),
				email : $("#emaile").val(),
				idCard : $("#idCard").val()
			},
			success : function(res) {
				if (res == 1) {
					alert("申请成功，等待审核")
					window.location.href = indexUrl
				}
			}
		})
	}
}
function fuyong() {
	if ($("#na").val() == " ") {
		alert("你未选择所属机构！")
	} else {
		$.ajax({
			type : "post",
			url : Server + "/userCenter/updateInfo",
			data : {
				uId : $("#useridoflogin").val(),
				unitName : $("#na").find("option:selected").text(),
				ouId: $("#na").val(),
				username : $("#userName").val(),
				realname : $("#realName").val(),
				post : $("#post").val(),
				phone : $("#mobile").val(),
				email : $("#emaile").val(),
				idCard : $("#idCard").val()
			},
			success : function(res) {
				console.log(res)
				if (res == 1) {
					alert("申请成功，等待审核")
					window.loaction.href = indexUrl
				}
			}
		})
	}
}
function update() {
	if ($("#na").val() == " ") {
		alert("你未选择所属机构！")
	} else {
		$.ajax({
			type : "post",
			url : Server + "/userCenter/selectApply",
			data : {
				cuId : $("#useridoflogin").val()
			},
			success : function(res) {
				console.log(res)
				if (res.length == 0) {
					fuyong()
				} else {
					for (var i = 0; i < res.length; i++) {
						if (res[i] == '6' || res[i] == '8') {
							alert("您还有尚未完成的订单，请在订单完成后重新提交审核")
							break;
						}
						if (i == res.length - 1) {
							fuyong()
						}
					}
				}
			}
		})
	}
}

function insert() {
	if ($("#na").val() == " ") {
		alert("你未选择所属机构！")
	} else {
		$.ajax({
			type : "post",
			url : Server + "/userCenter/selectApply",
			data : {
				cuId : $("#useridoflogin").val()
			},
			success : function(res) {
				console.log(res)
				if (res.length == 0) {
					submit()
				} else {
					for (var i = 0; i < res.length; i++) {
						if (res[i] == '6' || res[i] == '8') {
							alert("您还有尚未完成的订单，请在订单完成后重新提交审核")
							break;
						}
						if (i == res.length - 1) {
							submit()
						}
					}
				}
			}
		})
	}
}